import axios from './eco/base'

/**
 * 功能: 提交作答结果
 * insertList
 * updateList
 */
export const batchSave = (data) => {
  let params = {
    ...data
  }
  Object.keys(params).forEach((key) => {
    if (params[key] === '') {
      delete params[key]
    }
  })
  return axios.post('/zn-e-library/dataFormResult/batchSave', params).then(res => {
    return res
  })
}
export const noLoginBatchSave = (data) => {
  let params = {
    ...data
  }
  Object.keys(params).forEach((key) => {
    if (params[key] === '') {
      delete params[key]
    }
  })
  return axios.post('/zn-e-library/dataFormResult/noLogin/batchSave', params).then(res => {
    return res
  })
}

/**
 * 功能: 查询我的作答结果
 * condition
 */
export const myList = (data) => {
  let params = {
    pageNo: 1,
    pageSize: 10,
    ...data
  }
  Object.keys(params).forEach((key) => {
    if (params[key] === '') {
      delete params[key]
    }
  })
  return axios.post('/zn-e-library/dataFormResult/myList', params).then(res => {
    return res
  })
}
/**
 * 功能: 查询我的作答结果
 * condition
 */
export const myListNoLogin = (data) => {
  let params = {
    pageNo: 1,
    pageSize: 10,
    ...data
  }
  Object.keys(params).forEach((key) => {
    if (params[key] === '') {
      delete params[key]
    }
  })
  return axios.post('/zn-e-library/dataFormResult/noLogin/myList', params).then(res => {
    return res
  })
}
/**
 * 功能: 查询作答结果-根据条件
 */
export const list = (data) => {
  let params = {
    pageNo: 1,
    pageSize: 10,
    ...data
  }
  Object.keys(params).forEach((key) => {
    if (params[key] === '') {
      delete params[key]
    }
  })
  return axios.post('/zn-e-library/dataFormResult/list', params).then(res => {
    return res
  })
}

/**
 * 功能: 删除作答结果-按批次
 */
export const del = (data) => {
  return axios.post('/zn-e-library/dataFormResult/delete/' + data.id).then(res => {
    return res
  })
}

/**
 * 功能: 删除作答结果-按用户ID
 */
export const deleteByUserId = (data) => {
  return axios.post('/zn-e-library/dataFormResult/deleteByUserId', data).then(res => {
    return res
  })
}

/**
 * 功能: 查询作答结果-已填写人员
 */
export const dataCountUserList = (data) => {
  let params = {
    pageNo: 1,
    pageSize: 10,
    ...data
  }
  Object.keys(params).forEach((key) => {
    if (params[key] === '') {
      delete params[key]
    }
  })
  return axios.post('/zn-e-library/dataFormResult/noLogin/dataCountUserList', params).then(res => {
    return res
  })
}
// 未填写人员名单
export const dataCountNoUserList = (data) => {
  let params = {
    pageNo: 1,
    pageSize: 10,
    ...data
  }
  Object.keys(params).forEach((key) => {
    if (params[key] === '') {
      delete params[key]
    }
  })
  return axios.post('/zn-e-library/dataFormResult/noLogin/dataCountNoUserList', params).then(res => {
    return res
  })
}

/**
 * 功能: 查询作答结果-概况
 */
export const dataCountOverview = (data) => {
  let params = {
    pageNo: 1,
    pageSize: 10,
    ...data
  }
  Object.keys(params).forEach((key) => {
    if (params[key] === '') {
      delete params[key]
    }
  })
  return axios.post('/zn-e-library/dataFormResult/noLogin/dataCountOverview/' + data.formId, params).then(res => {
    return res
  })
}
/**
 * 功能: 查询作答结果-按题目显示
 */
export const dataCountFillQuestion = (data) => {
  let params = {
    pageNo: 1,
    pageSize: 10,
    ...data
  }
  Object.keys(params).forEach((key) => {
    if (params[key] === '') {
      delete params[key]
    }
  })
  return axios.post('/zn-e-library/dataFormResult/noLogin/dataCountFillQuestion/' + data.formId, params).then(res => {
    return res
  })
}

/**
 * 功能: 导出数据
 */
export const exportDataFormResult = (data) => {
  let params = {
    pageNo: 1,
    pageSize: 10,
    ...data
  }
  Object.keys(params).forEach((key) => {
    if (params[key] === '') {
      delete params[key]
    }
  })
  return axios.post('/zn-e-library/dataFormResult/exportDataFormResult', params).then(res => {
    return res
  })
}
/**
 * 功能: 导出数据
 */
export const getExportDataFormResultPath = (data) => {
  let params = {
    ...data
  }
  Object.keys(params).forEach((key) => {
    if (params[key] === '') {
      delete params[key]
    }
  })
  return axios.post('/zn-e-library/dataFormResult/getExportDataFormResultPath/' + data.formId).then(res => {
    return res
  })
}
